package br.ufpi.interceptor;

import br.com.caelum.vraptor.InterceptionException;
import br.com.caelum.vraptor.Intercepts;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.core.InterceptorStack;
import br.com.caelum.vraptor.interceptor.Interceptor;
import br.com.caelum.vraptor.resource.ResourceMethod;
import br.ufpi.annotation.PerfilDeAcesso;
import br.ufpi.componets.UserSession;

@Intercepts
public class PermissionInterceptor implements Interceptor {
	@SuppressWarnings("unused")
	private UserSession usuarioLogado;
	@SuppressWarnings("unused")
	private Result result;

	public PermissionInterceptor(UserSession usuarioLogado, Result result) {
		super();
		this.usuarioLogado = usuarioLogado;
		this.result = result;
	}

	@Override
	public void intercept(InterceptorStack stack, ResourceMethod method, Object resourceInstance) throws InterceptionException {
		
		// TODO Criar logica de quando deixar passar ou não requisição
	}

	@Override
	public boolean accepts(ResourceMethod method) {
		return (method.getMethod().isAnnotationPresent(PerfilDeAcesso.class));

	}

}
